/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.niuweb.isad.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

/**
 *
 * @author niuxg
 */
public class ArrayMap<K, V> implements Iterable<V> {
    private ArrayList<V> _array = new ArrayList<V>();
    private HashMap<K, V> _map = new HashMap<K, V>();
    
    public V get(K key){
        return _map.get(key);
    }
    
    public void push(K key, V value){
        _array.add(value);
        _map.put(key, value);
    }
    
    public V delete(K key){
        V value = _map.remove(key);
        _array.remove(value);
        return value;
    }

    @Override
    public Iterator<V> iterator() {
        return _array.iterator();
    }
}
